class Solution(object):
    def entityParser(self, text):
        new_t = []
        n = len(text)
        index = 0
        d = {'&quot;':'\"', '&apos;':'\'', '&amp;': '&', '&gt;':'>', '&lt;': '<', '&frasl;': '/'}
        while index < n:
            if text[index] == '&':
                if text[index: index + 4] in d:
                    new_t.append(d[text[index: index + 4]])
                    index += 4
                else:
                    if text[index: index + 5] in d:
                        new_t.append(d[text[index: index + 5]])
                        index += 5
                    else:
                        if text[index: index + 6] in d:
                            new_t.append(d[text[index: index + 6]])
                            index += 6
                        else:
                            if text[index: index + 7] in d:
                                new_t.append(d[text[index: index + 7]])
                                index += 7
                            else:
                                new_t.append(text[index])
                                index += 1
            else:
                new_t.append(text[index])
                index += 1
        return ''.join(new_t)